package org.bleep.input;

import org.lwjgl.input.Keyboard;

public abstract class Button
{
	protected String name;
	protected int keyCode;
	protected ButtonEventListener listener;
	
	public Button(String name, int keyCode)
	{
		this.name = name;
		this.keyCode = keyCode;
		listener = null;
	}
	
	public String getName()
	{
		return name;
	}
	
	public void update()
	{
		if (isActive() && listener != null)
		{
			ButtonEvent b = new ButtonEvent(name);
			listener.handleButtonEvent(b);
		}
	}
	
	public void registerButtonEventListener(ButtonEventListener listener)
	{
		this.listener = listener;
	}
	
	protected abstract boolean isActive();
}